package com.collect.senegal.zhiScene.zhiWidget.zhiDialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.collect.senegal.R;

public class ZHIDialogAppUpdate extends Dialog {

    private TextView negtiveBtn;
    private View.OnClickListener onClickButtonListener;

    private final Context context;

    public static void showAppUpdateDialog(Context context, View.OnClickListener onClickButtonListener) {
        ZHIDialogAppUpdate stupidDialogUpdate = new ZHIDialogAppUpdate(context);
        stupidDialogUpdate.setOnClickButtonListener(onClickButtonListener);
        stupidDialogUpdate.show();
    }

    public ZHIDialogAppUpdate(Context context) {
        super(context, R.style.CustomDialog);
        this.context = context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_app_update);
        setCanceledOnTouchOutside(false);
        initView();
        refreshViewData();
        initViewEvent();
    }

    @Override
    public void show() {
        super.show();
        refreshViewData();
    }

    /**
     * 初始化界面控件
     *
     * @type method
     * @author liwenjie
     * @creatTime 2019-10-24 13:47
     */
    private void initView() {
        negtiveBtn = (TextView) findViewById(R.id.btn_negtive);
    }

    /**
     * 初始化控件数据
     *
     * @type method
     * @author liwenjie
     * @creatTime 2019-10-24 13:51
     */
    private void refreshViewData() {

    }

    /**
     * 初始化控件事件
     *
     * @type method
     * @author liwenjie
     * @creatTime 2019-10-24 13:57
     */
    private void initViewEvent() {
        negtiveBtn.setOnClickListener(v -> {
            if (onClickButtonListener != null) {
                onClickButtonListener.onClick(v);
            }
        });
    }

    public void setOnClickButtonListener(View.OnClickListener onClickButtonListener) {
        this.onClickButtonListener = onClickButtonListener;
    }
}
